/**
 * User: xuqpa
 */

$(function() {
   
    var menuGroups = [
        {
            'menuId': "tenderMenu",
            'menuTitle': getLanMsg("投诉与建议"),
            'iconImg': null,
            'needShow': bModuleARAPOrSCM_PU,
            'items': [               
                {
                    'itemId': "tenderMenuItem1",                  
                    "itemUrl": "/ebvp/advorappcoll/appealrespcompl?complainoradvis=1",
                    'itemName': getLanMsg("投诉响应"),
            		'needShow': bModuleSCM_PU,
                    'callback': function() {window.location = "/ebvp/advorappcoll/appealrespcompl?complainoradvis=1"; return false;}                        
                },
                {
                    'itemId': "tenderMenuItem2",                  
                    "itemUrl": "/ebvp/advorappcoll/appealrespcompl?complainoradvis=0",
                    'itemName': getLanMsg("建议响应"),
            		'needShow': bModuleSCM_PU,
                    'callback': function() {window.location = "/ebvp/advorappcoll/appealrespcompl?complainoradvis=0";  return false;}
                    
                }
                
            ]
        }
    ];

    /* 左侧菜单栏 */
    $( "#columnLeft" ).UIColumnMenu({
        'menuGroups': menuGroups,
        'menuHeight': heigth,
        'singleGroup': true
    });
    
    $(function() {	
    	if(i==1){
			$( "#tenderMenuItem1" ).parents("ul").find(".current").removeClass("current");
			$( "#tenderMenuItem1" ).addClass("current");
    	}
    	if(i==0){
    		$( "#tenderMenuItem2" ).parents("ul").find(".current").removeClass("current");
    		$( "#tenderMenuItem2" ).addClass("current");
    	}
	 });

});

//上传附件
function uploadFile(){

	var url = ebvpContext+"/sourcingcoll/FileUpload_new.jsp";
	url = url + "?" + "uploadMode=4";
	url = url + "&" + "isNeedAddRow=Y";
	url = url + "&" + "pkReleaseFileB="+$("#pkcomplainrespor").val();
	url = url + "&" + "comflag="+$("#complainflag").val();
	var iTop = (window.screen.availHeight-30-330)/2;
	var iLeft = (window.screen.availWidth-10-620)/2;
	window.open(url,'' ,'width=620,height=330,location=no'+',top='+iTop+',left='+iLeft);
	return;
}

function addFileRow(pkReleaseFileB,replyFileName,replyFileSize,replyFilePath){
	
		var strDelBtn = "删除";
		var fileTable = document.getElementById("tenderListTableAff");
		var rowNo = fileTable.rows.length;
		var row = fileTable.insertRow(rowNo);
		row.id = rowNo;
		if(rowNo%2 == 0){
			row.className = 'odd';
		}
		
		//序号
		var cell = row.insertCell(0);
		cell.align = 'left';
		cell.innerHTML = "<input type='hidden' id='reply_file_real_path' name='reply_file_real_path' value='"+replyFilePath+"/"+replyFileName+"' />"+rowNo;
		
		//应答文件名称
		cell = row.insertCell(1);
		cell.align = 'left';
		cell.innerHTML = "<input disabled='true' type='text' id='reply_file_name' name='reply_file_name' class='textfield pd_5x2px' style='text-align:left;width:90%' value='"+replyFileName+"' />"; 
		
		//文件大小
		cell = row.insertCell(2);
		cell.align = 'left';
		if(replyFileSize/1048576 > 1){
			var FileSize = replyFileSize/1048576;
			cell.innerHTML = "<div>" + (FileSize.toFixed(2)) + "MB</div><input type='hidden' id='reply_file_size' name='reply_file_size' value='"+replyFileSize+"' maxlength='49' style='text-indent:0px;text-align:right' />";
		}else{
			var FileSize = replyFileSize/1024;
			cell.innerHTML = "<div>" + (FileSize.toFixed(2)) + "KB</div><input type='hidden' id='reply_file_size' name='reply_file_size' value='"+replyFileSize+"' maxlength='49' style='text-indent:0px;text-align:right'  />";
		}
		
		//备注
		cell = row.insertCell(3);
		cell.align = 'left';
		cell.innerHTML = "<input type='text' id='reply_file_memo' name='reply_file_memo' size='50' class='textfield pd_5x2px' style='width:90%'/>";
		
		//删除
		cell = row.insertCell(4);
		cell.align = 'left';
		cell.innerHTML = "<a class='btn_orange' id='onDelete' href='javascript:delFileName("+rowNo+");' style='margin-left:3px'><span class='w_34px h_18px ft_14px'>删除</span></a>";
	
}

//删除文件
function delFileName(index){
	var bidFileTable = document.getElementById("tenderListTableAff");
	if (bidFileTable != null) {
		// 获取报价信息有多少行
		var rows = bidFileTable.rows;
		if (rows != null && rows.length > 0) {
			for ( var pos = 0; pos < rows.length; pos++) {
				var row = rows[pos];
				// 寻找要删除的row
				if (row.id == index) {
					bidFileTable.deleteRow(pos);
					break;
				}
			}
		}
	}
}

//下载文件
function downloadFile(pk_file,file_path,file_name){
	document.form3.pk_file.value = pk_file;
	document.form3.file_path.value = file_path;
	document.form3.file_name.value = file_name;
	document.form3.action=ebvpContext+"/ebvpfile/download";
	document.form3.submit();
}

//小星星"非空验证"
$(document).ready(function(){
	$("#replynoteresp,#qryComplmentBenginDate,#qryComplmentEndDate").UITipInside({
		'required' : true,
		'cleaner' : false
	});
});

//非空校验

